GCCPREFIX :=
CC	:= $(GCCPREFIX)gcc
MPIPREFIX := mpi
MPICC := $(MPIPREFIX)cc 
MPIRUN := $(MPIPREFIX)run
MPICFLAGS := -g -Wall -lpthread -fopenmp -O2
CFLAGS1 := -g -lpthread -Wall 	-fopenmp -O2

mpimaster: mpitest 
	@echo "run ./mpi_test --master"
	$(MPIRUN) -np 1 ./mpi_test  


mpival: mpitest
	valgrind --tool=memcheck --leak-check=full $(MPIRUN) -np 2 xterm -e ./mpi_test

mpidebug: mpitest 
	$(MPIRUN) -np 4 xterm -e gdb ./mpi_test

mpi: mpitest
	@echo "run ./mpi_test"
	$(MPIRUN) -np 4 xterm -e ./mpi_test  

mpitest: mpi_test.o mpi_dpll_openmp.o mpi_dpll_pthread.o mpi_dpll.o mpi_dimac_parser.o mpi_clause.o mpi_cnf.o mpi_cdcl.o mpi_cdcl_dependence_graph.o mpi_myqueue.o mpi_slave_worker.o mpi_master.o mpi_encode_decode.o mpi_cdclmpi.o	
	$(MPICC) -o mpi_test $^ $(MPICFLAGS)

mpi_%.o:%.c
	$(MPICC) -c -o $@ $< $(MPICFLAGS)

pth: test
	@echo "run ./test"
	./test
win: test2
	objdump -S test-win.exe > test-win.S
	@echo "run ./test-exe"

test2: test.o dpll_openmp.o dpll_pthread.o dpll.o dimac_parser.o clause.o cnf.o timer.o util.o   	
	gcc -o test-win.exe $^ $(CFLAGS1)
	
test: test.o dpll_pthread.o dpll.o dimac_parser.o clause.o cnf.o timer.o util.o cdcl.o cdcl_dependence_graph.o myqueue.o
	gcc -o test $^ $(CFLAGS1)
%.o: %.c
	gcc -c -o $@ $< $(CFLAGS1)

clean:
	rm *.o
	rm test